<?
$_tok = new tokkotai;
$res =& $this->results['result'];
$num = count($res);
?>
<fieldset>
	<legend>Results</legend>
	<p>Your search returned <span class="b"><?=$num?></span> revision<? if($num != 1):?>s<? endif;?></p>

<?
if($this->charts && $num > 0):
?>
<div id="dCommits" class="chart"></div>
<script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="/js/highcharts.js"></script>
<!--[if IE]><script type="text/javascript" src="/js/excanvas.compiled.js"></script><![endif]-->
<script type="text/javascript">
var chart = new Highcharts.Chart
({
	chart: 
	{
		renderTo: 'dCommits',
		margin: [30,140,10,0]
	},
	title: 
	{
		text: 'Commits',
		style: { textAlign: 'left' }
	},
	plotArea: 
	{
		shadow: null,
		borderWidth: null,
		backgroundColor: null
	},
	tooltip: 
	{
		formatter: function() 
		{
			return '<b>'+ this.point.name +'</b>: '+ this.y;
		}
	},
	credits: { enabled: false },
	legend: 
	{
		layout: 'vertical',
		style: 
		{
			left: 'auto',
			bottom: 'auto',
			right: '0px',
			top: '10px'
		}
	},
	series: 
	[
		{
			type: 'pie',
			name: 'Commits',
			data: 
			[
			<?
			foreach($this->results['summary'] as $k=>$v):
				echo '["' . $k . '",' . $v . '],';
			endforeach;
			?>
			]
		}
	]
});
</script>
<?
endif;
?>
<table cellspacing="0" cellpadding="4" class="w100pc">
<?
$i = 0;
while($i < $num):
?>
	<tr>
		<th>Revision</th>
		<td><?=$res[$i]['rev']?></td>
	</tr>
	<tr>
		<th>Date</th>
		<td><?=date('l jS F Y H:i:s',strtotime($res[$i]['date']))?></td>
	</tr>
	<tr>
		<th>User</th>
		<td><?=$res[$i]['user']?></td>
	</tr>
	<tr>
		<th>Log</th>
		<td><?=nl2br(trim(htmlentities($res[$i]['log'])))?></td>
	</tr>
	<tr<? if($i != ($num - 1)):?> class="end"<? endif;?>>
		<td></td>
		<td>
		<table cellspacing="0" cellpadding="4">
		<?
		$j = 0;
		$numf = count($this->results['files'][$res[$i]['rev']]);
		while($j < $numf):
			$file =& $this->results['files'][$res[$i]['rev']][$j];
		?>
			<tr class="noend">
				<td><?=$file['action']?></td>
				<td>
					<?=$_tok->parse_path($file['resource'])?>
					<?
					if($_tok->get_file_extension($file['resource'])):
					?>
					[
						<?
						if($file['action'] == 'D'):
						?>
						<a href="view.php?id=<?=$file['id']?>&amp;prev">before</a>
						<?
						endif;
						?>
						<?
						if($file['action'] == 'A'):
						?>
						<a href="view.php?id=<?=$file['id']?>">view</a>
						<?
						endif;
						?>
						<?
						if($file['action'] == 'M'):
						?>
						<a href="view.php?id=<?=$file['id']?>">view</a>
						|
						<a href="view.php?id=<?=$file['id']?>&amp;prev">before</a>
						|
						<a href="diff.php?id=<?=$file['id']?>">diff</a>
						<?
						endif;
						?>
					]
					<?
					elseif($_tok->get_mimetype($file['resource'])):
					?>
						[
						<?
						if($file['action'] == 'D'):
						?>
						<a href="bin.php?id=<?=$file['id']?>&amp;prev">before</a>
						<?
						endif;
						?>
						<?
						if($file['action'] == 'A'):
						?>
						<a href="bin.php?id=<?=$file['id']?>">view</a>
						<?
						endif;
						?>
						<?
						if($file['action'] == 'M'):
						?>
						<a href="bin.php?id=<?=$file['id']?>">view</a>
						|
						<a href="bin.php?id=<?=$file['id']?>&amp;prev">before</a>
						<?
						endif;
						?>
						]
					<?
					endif;
					?>
				</td>
			</tr>
		<?
		++$j;
		endwhile;
		?>
		</table>
		</td>
	</tr>


<?
++$i;
endwhile;
?>
</table>
</fieldset>
